/*
 * commons is a based project implemented
 * Copyright (C) 2024 Jasmine
 */
package com.easy.ip.domain;

import java.io.Serial;
import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;

/**
 * ip 信息详情
 *
 * @author Jasmine
 * @since 1.0.0
 */

public class IpInfo implements Serializable {

    @Serial
    private static final long serialVersionUID = -5717843922727666185L;
    /**
     * 国家
     */
    private String country;
    /**
     * 省
     */
    private String province;
    /**
     * 城市
     */
    private String city;
    /**
     * 区域
     */
    private String region;
    /**
     * 运营商
     */
    private String isp;

    /**
     * 拼接完整的地址, 以空格区分
     *
     * @return address
     */
    public String getAddress() {
        Set<String> regionSet = new LinkedHashSet<>();
        regionSet.add(country);
        regionSet.add(province);
        regionSet.add(city);
        regionSet.add(region);
        regionSet.removeIf(Objects::isNull);
        return String.join(" ", regionSet);
    }

    /**
     * 拼接完整的地址
     *
     * @return address
     */
    public String getAddressAndIsp() {
        Set<String> regionSet = new LinkedHashSet<>();
        regionSet.add(country);
        regionSet.add(province);
        regionSet.add(city);
        regionSet.add(region);
        regionSet.add(isp);
        regionSet.removeIf(Objects::isNull);
        return String.join(" ", regionSet);
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getIsp() {
        return isp;
    }

    public void setIsp(String isp) {
        this.isp = isp;
    }
}
